package Server;
/* file comment */
/**
 * @author David
 * @version $Revision: 1.0 $
 */
public class ProtocolParser {
	/**
	 * Field tokens.
	 */
	private final String[] tokens;

	/**
	 * Constructor for ProtocolParser.
	 * @param line String
	 */
	public ProtocolParser(String line) {
		this.tokens = line.split(" ");	//String has the form ==> [username password]
		
	}
	
	/**
	 * Method toString.
	 * @return String
	 */
	public String toString(){
		final String str = "";
		return str;
	}

	/**
	 * Method checkPassword.
	 * @param handler Object
	 * @return Boolean
	 */
	public Boolean checkPassword(Object handler) {
		//Admin adm = Admin.getInstance();
		final Admin adm = new Admin("Admin", "Password");
			
		final User user = adm.findUser(tokens[0]);
		if (user != null){
			if (user.validate(tokens[1])) {
				//handler.setUser(user);	//the class that sends its String message should be able 
											//to set the user as logged in since it was validated
				user.setLoggedIn(true);
				return true;
			}
			
		}
		return false;
		
		
		
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

}
